<?php

namespace plugin\wechat\app\admin\controller;

use app\common\service\App as AppService;
use plugin\wechat\app\AdminController;
use support\Response;

class Index extends AdminController
{

    public function index()
    {
        return $this->show();
    }

    public function welcome(){
        $assign = [

        ];
        return $this->show($assign);
    }

    /**
     * 获取初始化数据
     * @return Response
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author: fudaoji<fdj@kuryun.cn>
     */
    public function getSystemInit(){
        $app_info = AppService::getApp(request()->plugin);
        $homeInfo = [
            'title' => '首页',
            'href'  => url('index/welcome'),
        ];
        $logoInfo = [
            'title' => $app_info['title'],
            'href' => url('index/index'),
            'image' => $app_info['logo']
        ];

        $menuInfo = \plugin\wechat\app\admin\service\Auth::getMenuList($this->adminInfo());
        $systemInit = [
            'homeInfo' => $homeInfo,
            'logoInfo' => $logoInfo,
            'menuInfo' => $menuInfo,
        ];
        return json($systemInit);
    }
}
